<!DOCTYPE HTML>
<link rel="help" href="http://url.spec.whatwg.org/#dom-url-href">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>

test(function() {
    var url = new URL('http://www.domain.com/');
    assert_equals(url.href, 'http://www.domain.com/');
    assert_equals(url.href, url.toString());

    url.href = 'mailto:foo@bar.com';
    assert_equals(url.href, 'mailto:foo@bar.com');

}, 'href property');

test(function() {
    var orig = 'http://abc.de/path/file?query#fragment'
    var url = new URL(orig);
    assert_equals(url.href, orig);

    assert_throws_js(TypeError, () => { url.href = 'invalid'; });
    assert_equals(url.href, orig);
}, 'setting href to an invalid URL');

test(function() {
    var orig = 'http://domain.com/';
    var url = new URL(orig);
    assert_throws_js(TypeError, () => { url.href = null; });
    assert_equals(url.href, orig);
}, 'setting href to null');

</script>
